<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <div class="father clearfix">
        <div class="big"></div>
        <div class="small"></div>
        <!-- <div class="clear">额外标签法</div> -->
    </div>
    <div class="test"></div>
</head>

<body>
    <style>
        /* 1.父级添加overflow属性 */
        .father {
            border: 1px solid red;
            width: 400px;
            /* overflow: hidden; */
        }

        .big {
            width: 200px;
            height: 200px;
            background-color: green;
            float: left;
        }

        .small {
            width: 100px;
            height: 100px;
            background-color: pink;
            float: left;
        }

        .test {
            width: 400px;
            height: 100px;
            background-color: greenyellow;
        }
        /* 2.额外标签法 */
        /* .clear {
            clear: both;
        } */

        /* 3.使用after伪元素清除浮动（推荐使用） */
        .clearfix:after {
            /*伪元素是行内元素 正常浏览器清除浮动方法*/
            content: "";
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;
        }

        /* 4.使用before和after双伪元素清除浮动 */
        .clearfix:after,
        .clearfix:before {
            content: "";
            display: table;
        }

        .clearfix:after {
            clear: both;
        }
    </style>
</body>

</html>